import request from '_utils/request'

// 封装请求 商品分类结构
const fetchCates = (params = {}) => {
  return request.get('/shop/goods/category/all', { params })
}
// 获取首页轮播
const fetchBanner = (params = {}) => request.get('/banner/list', { params })

// 获取商品列表
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)

// 获取商品详情  /shop/goods/detail
const fetchDetail = (params = {}) => request.get('/shop/goods/detail', { params })
// 用户注册
const doRegister = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const doLogin = (params = {}) => request.post('/user/username/login', params)
const addCart = (params = {}) => request.post('/shopping-cart/add', params)

// 获取购物车数据
const fetchCartInfo = (params = {}) => request.get('/shopping-cart/info', { params })
// 增加购买数量
const addItemNumber = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 删除购物车中某条商品
const delCartItem = (params = {}) => request.post('/shopping-cart/remove', params)
// 修改购物车中 商品的 状态
const setItemSelected = (params = {}) => request.post('/shopping-cart/select', params)
// 获取默认收货人
const getDefaultContact = (params = {}) => request.get('/user/shipping-address/default/v2', { params })
// 获取收货人详情
const getContact = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 添加联系人
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 获取联系人列表
const fetchContactLists = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 获取联系人 详情
const fetchContactDetail = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 更新联系人
const updateContact = (params = {}) => request.post('/user/shipping-address/update', params)
export {
  fetchCates,
  fetchBanner,
  fetchItems,
  fetchDetail,
  doRegister,
  doLogin,
  addCart,
  fetchCartInfo,
  addItemNumber,
  delCartItem,
  setItemSelected,
  getDefaultContact,
  addContact,
  fetchContactLists,
  fetchContactDetail,
  updateContact,
  getContact
}
